<?php

class Application_Form_SupplierForm extends Zend_Form
{
    public function getStatusSupplier()
    {
        $status = new Application_Model_Statussupplier();
        $status = $status->fetchAll();
        $stat = array();
        foreach ($status as $status)
        {
            $stat[$status->id_status_supplier] = $status->status_supplier;
        }
        
        /* @var $stat ArrayObject */
        return $stat;
    }
    public function init()
    {
        $this->setMethod('post');
        
        $id_supplier = new Zend_Form_Element_Hidden('id_supplier');
        
        $nama_supplier = new Zend_Form_Element_Text('nama_supplier');
        $nama_supplier->setLabel('Nama Supplier')->setRequired();
        
        $alamat_supplier = new Zend_Form_Element_Textarea('alamat_supplier');
        $alamat_supplier->setLabel('Alamat')->setAttribs(array('cols'=>60,'rows'=>10))->setRequired();
        
        $provinsi = new Zend_Form_Element_Text('provinsi');
        $provinsi->setLabel('Provinsi');
        
        $negara = new Zend_Form_Element_Text('negara');
        $negara->setLabel('Negara');
        
        $kodepos = new Zend_Form_Element_Text('kode_pos');
        $kodepos->setLabel('Kode Pos');
        
        $no_telepon_1 = new Zend_Form_Element_Text('telepon_1');
        $no_telepon_1->setLabel('No Telepon 1')->setRequired();
        
        $no_telepon_2 = new Zend_Form_Element_Text('telepon_2');
        $no_telepon_2->setLabel('No Telepon 2')->addValidator('Digits');
        
        $no_fax = new Zend_Form_Element_Text('fax');
        $no_fax->setLabel('No Fax.');
        
        $email = new Zend_Form_Element_Text('email_supplier');
        $email->setLabel('E-mail')->addValidator('EmailAddress');
        
        $web = new Zend_Form_Element_Text('website_supplier');
        $web->setLabel('Website');
        
        $keterangan_supplier = new Zend_Form_Element_Textarea('keterangan_supplier');
        $keterangan_supplier->setLabel('Keterangan')->setAttribs(array('cols'=>60,'rows'=>10));
        
        $status = new Zend_Form_Element_Select('id_status_supplier');
        $status->setLabel('Status')->setMultiOptions($this->getStatusSupplier());
        
        $submit = new Zend_Form_Element_Submit('submit');
        $submit->setLabel('Tambah');
        
        $ulang = new Zend_Form_Element_Reset('ulang');
        $ulang->setLabel('Ulang');

        $this->addElements(array($nama_supplier, $alamat_supplier, $provinsi, $negara, $kodepos, 
            $no_telepon_1, $no_telepon_2, $no_fax, $email, $web, $keterangan_supplier, $status, 
            $submit, $ulang, $id_supplier));
        
    }
}